<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link rel="stylesheet" type="text/css" href="css/css.css" />
    <link rel="stylesheet" type="text/css" href="css/style.css" />
    <script type="text/javascript"
            src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script src="layer/layer.js" type="text/javascript"></script>
    <script src="js/main.js" type="text/javascript"></script>
    <title>登录</title>
</head>
<body>
<!--login begin-->
<div class="m-login">
    <div class="login-logo">
        <img src="images/common/logo.png"/>
    </div>
    <div class="login-title border-bot login-redcolor"
         style="font-weight: normal">账号密码登陆
    </div>
    <div class="input-box  border-bot">
        <img src="images/login/icon-phone.png"/><input id="userTel" value="13100000000" type="text" placeholder="请输入手机号" class="input-box1"/>
    </div>
    <div class="input-box  border-bot">
        <img src="images/login/icon-password.png"/><input id="userPwd" value="123456" type="text" placeholder="密码，长度6-20字符" class="input-box1"/>
    </div>
    <div class="input-box" style="text-align: left">
        <a href="register.jsp" class="login-redcolor"
           style="text-decoration: underline; font-size: 18px">快速注册</a></span>
    </div>
    <div class="input-box "></div>
    <div class="login-me cursor" onclick="login()">
        <button class="cursor">登陆</button>
    </div>
</div>
<!--login end-->
<script>
    function login() {
        //获取登录的参数
        var userTel = $.trim($("#userTel").val());
        var userPwd = $.trim($("#userPwd").val());
        //手机号码正则
        var telTest = /^1[3|4|5|8][0-9]\d{4,8}$/;
        if (!telTest.test(userTel)) {
            layer.msg('请输入有效的手机号码');
        }else if(userPwd.length < 6 || userPwd.length > 20){
            layer.msg('请输入6~20位密码');
        }else{
            $.post("UserServlet/login",{"userTel":userTel,"userPwd":userPwd},function (data) {
                if(data == 0)
                    layer.msg('手机号码或者密码错误');
                else if(data == -1)
                    layer.msg('用户已被停用');
                else
                    top.location.reload();
            },"text");
        }
    }
</script>
</body>
</html>
